library(tidyverse)

source("helpers_v2.R")

# loading data
source("../load_data.R")

generate_features <- function(eventdata) {
  
  observable_counts <- eventdata %>%
    group_by(STUDENTID, Observable) %>%
    summarise(Count = n(), .groups = 'drop') %>%
    pivot_wider(names_from = Observable, values_from = Count, values_fill = list(Count = 0))
  observable_counts$STUDENTID<-as.character(observable_counts$STUDENTID)
  names(observable_counts) <- gsub(" ", "", names(observable_counts))
  observable_counts
}



test_features_obsct <- generate_features(testBlockA)

train_features_obsct <- generate_features(trainBlockA)

save(test_features_obsct,train_features_obsct,
     file = "features_obsct.Rdata")